package com.stylefeng.guns.rest.modular.banner.controller;

import com.stylefeng.guns.rest.common.CommonResponse;
import com.stylefeng.guns.rest.modular.attent.controller.dto.AttentHotRequest;
import com.stylefeng.guns.rest.modular.banner.controller.dto.BannerRequest;
import com.stylefeng.guns.rest.modular.banner.service.BannerService;
import org.apache.commons.logging.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 轮播图控制器
 */
@RestController
@RequestMapping("/banners")
public class BannerController {
    private final Log logger = org.apache.commons.logging.LogFactory.getLog(this.getClass());
    @Autowired
    private BannerService bannerService;


    /**
     * 获取轮播图列表
     * @param request
     * @return
     */
    @RequestMapping(value = "/getBannerList", method = RequestMethod.POST)
    public ResponseEntity<?> getBannerList(@RequestBody BannerRequest request){
        if(request.getPage()==0){
            request.setPage(1);
        }
        if(request.getSize()==0){
            request.setSize(5);
        }
        return ResponseEntity.ok(CommonResponse.ok("操作成功" , bannerService.getBannerList(request)));

    }
}
